package com.hurl.stock.biz.jcsj;

import java.io.IOException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.hurl.stock.persistence.PersistentBO;
import com.hurl.stock.util.HttpUtils;

public abstract class DSBuilder{
	private static Log log = LogFactory.getLog(DSBuilder.class);
	public PersistentBO build(DSLocation location) throws JcsjException {
		String responseText = null;
		try {
			String uri = location.getURI();
			log.debug("request uri: "+uri);
			responseText = HttpUtils.executeGetMethod(uri);
			log.debug("response text: "+responseText);
		}catch (IOException e) {
			throw new JcsjException("Failed to request '"+location.getURI()+"'.",e);
		}
		return processResponseText(responseText,location);
	}
	public abstract PersistentBO processResponseText(String responseText,DSLocation location);
}
